home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / nan_news / vol3 / no3 / netfopen.prg < prev    next >
Text File  |  1988-11-01  |  1KB  |  41 lines

  1. * Function: Net_fopen()
  2. * Author:   David Morgan
  3. * Version:  Clipper Summer '87
  4. * Note(s):  Tries to open a file with specified open mode.
  5. *
  6. * Copyright (c) 1988 Nantucket Corp.
  7.  
  8. FUNCTION Net_fopen
  9.  
  10. * Pass the following parameters:
  11. *
  12. * 1. Character - name of the file to open.
  13. *
  14. * 2. Logical or Numeric - mode of open.
  15. *
  16. *    if logical: .T. = Deny Read/Write-R/W (146).
  17. *                .F. = Deny None-R/W (194).
  18. *    if numeric: you name it per DOS 3Dh/INT 21h,
  19. *                this value as open mode.
  20. *
  21. * 3. Numeric - seconds to wait (0 = wait forever).
  22.  
  23. PARAMETERS file, ex_use, wait
  24. PRIVATE forever, handl, keystroke, open_mode
  25. open_mode = IIF (  TYPE('ex_use') ='L'  ,;
  26.                    IIF(ex_use,146,194)  ,;
  27.                    ex_use)
  28. forever = (wait = 0)
  29. DO WHILE (forever .OR. wait > 0)
  30.    handl = FOPEN(file, open_mode)
  31.    IF handl > -1                && FOPEN succeeds.
  32.       RETURN (handl)
  33.    ENDIF
  34.    keystroke = INKEY(1)            && Wait 1 second.
  35.    IF keystroke = 27
  36.       BREAK
  37.    END
  38.    wait = wait - 1
  39. ENDDO
  40. RETURN handl             && FOPEN fails: handl is -1.
  41.